#include <iostream>
using namespace std;
int a, b, c, d;
int f(int x)
{
	a = x % 10;
	x /= 10;
	b = x % 10;
	x /= 10;
	c = x % 10;
	x /= 10;
	d = x % 10;
	if ((b == d)&& a - 1 == c)
	{
		return 1;
	}
	return 0;
}
int main()
{
	int n = 5;
	int arr[6];
	int i = 0;
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	int count=0;
	for (i = 0;i < n;i++)
	{
		if (f(arr[i]) == 1)
			count++;
	}
	cout << count;
	return 0;
}